package org.nxt.ask;

import java.awt.TrayIcon;

import org.asteriskjava.manager.ManagerEventListener;
import org.asteriskjava.manager.event.JoinEvent;
import org.asteriskjava.manager.event.ManagerEvent;

public class Eventos implements ManagerEventListener {
	
	public TrayIcon trayIcon;
	
	public Eventos(TrayIcon trayIcon) {
		this.trayIcon = trayIcon;
	}

	@Override
	public void onManagerEvent(ManagerEvent event) {
		//System.out.println(event);
		if(event instanceof JoinEvent) {
			displayMessage((JoinEvent)event);
		}
	}
	
	public void displayMessage(JoinEvent evt) {
		System.out.println(evt);
		System.out.println(evt.getQueue());
		System.out.println(evt.getCallerIdNum());
		if(trayIcon == null) System.out.println("TRAYICON ES NULO");
		trayIcon.displayMessage("Entrada en cola", evt.getQueue() + " " + evt.getCallerIdNum(), TrayIcon.MessageType.INFO);
	}

}
